<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width = device-width, initial-scale = 1.0, minimum-scale = 1.0, maximum-scale = 1.0, user-scalable = no"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>ajax演示</title>
<script src="ajax.js" type="text/javascript"></script>
</head>
<body>
<style>
*{margin:0;padding:0;}
</style>

<input type="file" id="file" name="file" multiple>
<button id="btn">点击上传文件(利用FormData)</button>

<script>
document.getElementById('btn').onclick=function(){
        var fd=new FormData()
        fd.append('paper',document.getElementById('file').files[0]);
        fd.append('age',99)
        ajaxFD({
            url:'server.php',
            data:fd,
            success:function(res){
                document.title='成功'+res.a.name
            },
            error:function(text,code){
                document.title='失败'+'-'+text+'-'+code
            }
        })
}
</script>
</body>
</html>
